home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / AOCE / Development Tools / Sample Code / Standard Catalog Package / DTS AddressOMatic / Src / AOMPanelEvent.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-14  |  16.7 KB  |  613 lines  |  [TEXT/KAHL]

  1. /*                                    AOMPanelEvent.c                                */
  2. /*
  3.  * AddressOMatic Sample
  4.  * AOMPanelEvent.c
  5.  * Copyright © 1993 Apple Computer Inc. All rights reserved.
  6.  */
  7. #include "AddressOMaticPrivate.h"
  8. #include <OCEStandardMail.h>
  9. enum {                                        /* Keyboard commands    */
  10.     NUL                    = 0,                /* NUL == EOS            */
  11.     charEnter            = 0x03,                /* Enter key            */
  12.     charTab                = '\t',                /* Tab key                */
  13.     charReturn            = 0x1D,                /* Return key            */
  14.     charEscape            = 0x1B                /* Stop key                */
  15. };
  16.  
  17. OSErr                            _AOMMouseEvent(
  18.         register AddressOMaticPtr    aomPtr,
  19.         const EventRecord            *theEvent,
  20.         register AOMPanelState        *whatHappened
  21.     );
  22. AOMModeBit                        _AOMTrackRadioButton(
  23.         AddressOMaticPtr            aomPtr,
  24.         Point                        mousePt,
  25.         short                        index
  26.     );
  27. AOMPanelState                    _AOMDoToButtonHit(
  28.         AddressOMaticPtr            aomPtr,
  29.         Boolean                        isButtonHit
  30.     );
  31. AOMPanelState                    _AOMDoEnterKey(
  32.         AddressOMaticPtr            aomPtr
  33.     );
  34. /*
  35.  * Call on every event (even update events)
  36.  */
  37. pascal OSErr
  38. AOMPanelEvent(
  39.         AddressOMaticPtr            aomPtr,                /* The panel            */
  40.         const EventRecord            *theEvent,            /* The event            */
  41.         register AOMPanelState        *whatHappened        /* Result                */
  42.     )
  43. {
  44.         OSErr                        status;
  45.         WindowPtr                    theWindow;
  46.         Boolean                        isActivating;
  47.         SDPPanelState                panelState;
  48.         SDPFindPanelResult            findResult;
  49.         unsigned short                theChar;
  50.         SDPPanelHandle                thePanel;
  51.         short                        eventWhat;
  52.         Boolean                        findWasFinding;
  53.         AOMSaveState                saveState;
  54.         
  55. #define EVENT    (*theEvent)
  56. #define STATE    (*whatHappened)
  57.  
  58.         STATE = kAOMAppMustHandleEventMask;
  59.         status = noErr;
  60.         /*
  61.          * Since theEvent is a const, we can't set theEvent->what
  62.          * to skip events. This is a hack.
  63.          */
  64.         eventWhat = EVENT.what;
  65.         /*
  66.          * TBS: Call the SDP Browse and Find event handlers
  67.          * and merge their state values into the STATE variable.
  68.          * Clear kAOMAppMustHandleEventBit if the SDP routines
  69.          * handled the event. The following is needed only if
  70.          * we must handle the event.
  71.          * NOTE: Do not pass an update event to the
  72.          * SDP Panel Event function. Pass mouse events only
  73.          * if in the panel itself.
  74.          */
  75.         if ((EVENT.modifiers & optionKey) != AOM.optKeyDown) {
  76.             AOM.optKeyDown = EVENT.modifiers & optionKey;
  77.             AOM.buttonUpdateNeeded = TRUE;
  78.         }
  79.         if (eventWhat != updateEvt && eventWhat != mouseDown) {
  80.             if (eventWhat != nullEvent)
  81.                 AOM.buttonUpdateNeeded = TRUE;
  82.             switch (AOM.currentMode) {
  83.             case kAOMEnablePDBit:
  84.                 thePanel = AOM.pdPanel;
  85.                 goto panelEvent;
  86.             case kAOMEnablePanelBit:
  87.                 thePanel = AOM.browsePanel;
  88. panelEvent:        _AOMSaveState(aomPtr, kAOMTextFontStyle, &saveState);
  89.                 status = SDPPanelEvent(thePanel, theEvent, &panelState);
  90.                 _AOMRestoreState(&saveState);
  91.                 LOG(status, "\pSDPPanelEvent");
  92.                 if (status == noErr && panelState == kSDPSelectedAnItem) {
  93.                     STATE |= kAOMSelectedAnItemMask;
  94.                     _AOMFlashButton(aomPtr, AOM.toButton);
  95.                     STATE |= (AOM.optKeyDown)
  96.                             ? kAOMSaveButtonHitMask
  97.                             : kAOMToButtonHitMask;
  98.                 }
  99.                 break;
  100.             case kAOMEnableFindBit:
  101.                 findWasFinding = FINDING;
  102.                 _AOMSaveState(aomPtr, kAOMTextFontStyle, &saveState);
  103.                 status = SDPFindPanelEvent(AOM.findPanel, theEvent, &findResult);
  104.                 _AOMRestoreState(&saveState);
  105.                 LOG(status, "\pSDPFindPanelEvent");
  106.                 /*
  107.                  * Hack: if the user types <Return> or <Enter>, and there is text to be
  108.                  * found, the FindPanel starts or stops up immediately. This confuses
  109.                  * our own logic. We test for this condition and force the event
  110.                  * to "null event" in this case.
  111.                  */
  112.                 if (status == noErr
  113.                  && (eventWhat == keyDown || eventWhat == autoKey)) {
  114.                      theChar = EVENT.message & charCodeMask;
  115.                      if (theChar == charReturn || theChar == charEnter) {
  116.                         /*
  117.                          * The user hit "enter" key. Don't process it in the next
  118.                          * section. _AOMFlashButton will fix the button state.
  119.                          */
  120.                          eventWhat = nullEvent;
  121.                         _AOMFlashButton(aomPtr, AOM.toButton);
  122.                     }
  123.                 }
  124.                 if (status == noErr && findResult != 0) {
  125.                     if (findResult == kSDPSelectedAFindItem) {
  126.                         STATE |= kAOMSelectedAnItemMask;
  127.                         _AOMFlashButton(aomPtr, AOM.toButton);
  128.                         STATE |= (AOM.optKeyDown)
  129.                                 ? kAOMSaveButtonHitMask
  130.                                 : kAOMToButtonHitMask;
  131.                     }
  132.                 }
  133.                 break;
  134. #ifdef ENABLE_TYPEIN
  135.             case kAOMEnableTypeInBit:
  136.                 status = _AOMTypeInEvent(aomPtr, theEvent, whatHappened);
  137.                 LOG(status, "\p_AOMTypeInEvent");
  138.                 break;
  139. #endif
  140.             }
  141.         }
  142.         if (status == noErr) {
  143.             switch (eventWhat) {
  144.             case nullEvent:
  145.                 break;
  146.             case keyDown:
  147.             case autoKey:
  148.                 theChar = EVENT.message & charCodeMask;
  149.                 /*
  150.                  * TBS: use the "approved" test for <CMD><PERIOD>.
  151.                  */
  152.                 if (theChar == '.' && (EVENT.modifiers & cmdKey) != 0) {
  153.                     /*
  154.                      * TBS: Stop Find, Stop Browse, Stop spinning.
  155.                      */
  156.                     AOM.buttonUpdateNeeded = TRUE;
  157.                 }
  158.                 else if (theChar == charTab) {
  159.                     /* TBS */
  160.                 }
  161.                 else if (theChar == charReturn || theChar == charEnter)
  162.                       STATE = _AOMDoEnterKey(aomPtr);
  163.                 else {
  164.                     /* Nothing (Type-in did it's thing already) */
  165.                 }
  166.                 break;
  167.             case mouseDown:
  168.                 status = _AOMMouseEvent(aomPtr, theEvent, whatHappened);
  169.                 break;
  170.             case updateEvt:
  171.                 break;
  172.             case activateEvt:
  173.                 theWindow = (WindowPtr) EVENT.message;
  174.                 isActivating = ((EVENT.modifiers & activeFlag) != 0);
  175.                 goto activateEvent;
  176.                 break;
  177.             case osEvt:
  178.                 switch (((unsigned long) EVENT.message) >> 24) {
  179.                 case mouseMovedMessage:
  180.                     break;
  181.                 case suspendResumeMessage:
  182.                     isActivating = ((EVENT.message & 0x01) != 0);
  183.                     theWindow = FrontWindow();
  184. activateEvent:        if (theWindow == AOM.window) {
  185.                         /*
  186.                          * The SDP and Type-in handlers did the work
  187.                          */
  188.                     }
  189.                     break;
  190.                 }
  191.                 break;
  192.             }
  193.         }
  194.         if (AOM.buttonUpdateNeeded)
  195.             _AOMSetButtonText(aomPtr);
  196.         if (FINDING)
  197.             STATE |= kAOMFindInProgressMask;
  198.         LOG(status, "\pAOMPanelEvent exit");
  199.         return (status);
  200. #undef EVENT
  201. #undef STATE
  202. }
  203.  
  204. OSErr
  205. _AOMMouseEvent(
  206.         register AddressOMaticPtr    aomPtr,
  207.         const EventRecord            *theEvent,
  208.         register AOMPanelState        *whatHappened
  209.     )
  210. {
  211.         OSErr                        status;
  212.         WindowPtr                    theWindow;
  213.         AOMSaveState                saveState;
  214.         Boolean                        clickInPanel;
  215.         short                        partCode;
  216.         Point                        mousePt;
  217.         ControlHandle                theControl;
  218.         short                        i;
  219.         AOMModeBit                    newMode;
  220.         SDPPanelState                panelState;
  221.         SDPFindPanelResult            findResult;
  222.         SDPPanelHandle                thePanel;
  223. #define EVENT    (*theEvent)
  224. #define STATE    (*whatHappened)
  225.  
  226.         status = noErr;
  227.         /*
  228.          * TBS: if the mouse point is outside the AOM Panel,
  229.          * and we were the target,  set the "AppBecomesTarget" bit.
  230.          * If inside the AOM panel (and we weren't the target), set
  231.          * the "PanelBecomesTarget" bit). We should track the
  232.          * AppleLetter logic here.
  233.          */
  234.         partCode = FindWindow(EVENT.where, &theWindow);
  235.         if (theWindow == AOM.window) {
  236.             _AOMSaveState(aomPtr, kAOMLabelFontStyle, &saveState);
  237.             mousePt = EVENT.where;
  238.             GlobalToLocal(&mousePt);
  239.             clickInPanel = PtInRect(mousePt, &BOUNDS);
  240.             if (AOM.isTarget && clickInPanel == FALSE)
  241.                 STATE |= kAOMAppBecomesTargetMask;
  242.             else if (AOM.isTarget == FALSE && clickInPanel)
  243.                 STATE |= kAOMPanelBecomesTargetMask;
  244.             AOM.isTarget = clickInPanel;
  245.             if (clickInPanel) {
  246.                 /*
  247.                  * Click in our panel. Check for a button.
  248.                  * Note that we handle these events.
  249.                  */
  250.                 if (PtInRect(mousePt, &PANEL)) {
  251.                     switch (AOM.currentMode) {
  252.                     case kAOMEnablePDBit:
  253.                         thePanel = AOM.pdPanel;
  254.                         goto clickInPanel;
  255.                         break;
  256.                     case kAOMEnablePanelBit:
  257.                         thePanel = AOM.browsePanel;
  258. clickInPanel:            status = _AOMPanelSetFocus(aomPtr, thePanel, TRUE);
  259.                         status = SDPPanelEvent(thePanel, theEvent, &panelState);
  260.                         LOG(status, "\pSDPPanelEvent");
  261.                         if (status == noErr && panelState == kSDPSelectedAnItem) {
  262.                             STATE |= kAOMSelectedAnItemMask;
  263.                             _AOMFlashButton(aomPtr, AOM.toButton);
  264.                             STATE |= (AOM.optKeyDown)
  265.                                     ? kAOMBCCButtonHitMask
  266.                                     : kAOMCCButtonHitMask;
  267.                         }
  268.                         break;
  269.                     case kAOMEnableFindBit:
  270.                         status = SDPFindPanelEvent(AOM.findPanel, theEvent, &findResult);
  271.                         LOG(status, "\pSDPFindPanelEvent");
  272.                         if (status == noErr && findResult != 0) {
  273.                             if (findResult == kSDPSelectedAFindItem) {
  274.                                 STATE |= kAOMSelectedAnItemMask;
  275.                                 _AOMFlashButton(aomPtr, AOM.toButton);
  276.                                 STATE |= (AOM.optKeyDown)
  277.                                         ? kAOMBCCButtonHitMask
  278.                                         : kAOMCCButtonHitMask;
  279.                             }
  280.                         }
  281.                         break;
  282. #ifdef ENABLE_TYPEIN
  283.                     case kAOMEnableTypeInBit:
  284.                         status = _AOMTypeInEvent(aomPtr, theEvent, whatHappened);
  285.                         LOG(status, "\p_AOMTypeInEvent");
  286.                         break;
  287. #endif
  288.                     }
  289.                     STATE &= ~kAOMAppMustHandleEventMask;
  290.                 }
  291.                 else if (partCode == inContent) {
  292.                     partCode = FindControl(mousePt, theWindow, &theControl);
  293.                     if (partCode == inButton) {
  294.                         partCode = TrackControl(theControl, mousePt, NULL);
  295.                         if (partCode != 0) {
  296.                             /*
  297.                              * User clicked on a button. Return the
  298.                              * button state.
  299.                              */
  300.                             if (theControl == AOM.doneButton)
  301.                                 STATE |= kAOMDoneButtonHitMask;
  302.                             else if (theControl == AOM.ccButton
  303.                                   && ControlEnabled(AOM.ccButton)) {
  304.                                 STATE |=
  305.                                     (AOM.optKeyDown)
  306.                                         ? kAOMBCCButtonHitMask
  307.                                         : kAOMCCButtonHitMask;
  308.                             }
  309.                             else if (theControl == AOM.toButton
  310.                                   && ControlEnabled(AOM.toButton)) {
  311.                                 STATE |= _AOMDoToButtonHit(aomPtr, TRUE);
  312.                             }
  313.                             STATE &= ~kAOMAppMustHandleEventMask;
  314.                         }                            /* If button click            */
  315.                     }                                /* In an action button        */
  316.                     else {                            /* Not in an action button    */
  317.                         /*
  318.                          * Check for a radio "button." These are implemented
  319.                          * as "hotRects" -- we do the TrackControl here.
  320.                          */
  321.                         newMode = AOM.currentMode;
  322.                         for (i = 0; i < kAOMRadioButtons; i++) {
  323.                             if (PtInRect(mousePt, &RADIO(i))) {
  324.                                 newMode = _AOMTrackRadioButton(aomPtr, mousePt, i);
  325.                                 break;
  326.                             }
  327.                         }
  328.                         if (newMode != AOM.currentMode)
  329.                             _AOMSelectMode(aomPtr, newMode);
  330.                     }                                /* Not in an action button    */
  331.                 }                                    /* In panel content            */
  332.             }                                        /* Click in AOM panel        */
  333.             _AOMRestoreState(&saveState);
  334.         }                                            /* Click in our window        */
  335.         LOG(status, "\p_AOMMouseEvent");
  336.         return (status);
  337. #undef EVENT
  338. #undef STATE
  339. }
  340.  
  341. /*
  342.  * The mouse hit one of our radio buttons. If it's already selected,
  343.  * just ignore it. Else, track the button. If the user selects the
  344.  * new button, return the new mode.
  345.  */
  346. AOMModeBit
  347. _AOMTrackRadioButton(
  348.         register AddressOMaticPtr    aomPtr,
  349.         Point                        mousePt,
  350.         short                        index
  351.     )
  352. {
  353.         register AOMRadioButtonPtr    buttonPtr;
  354.         Rect                        hitRect;
  355.         Boolean                        inHitRect;
  356.         Boolean                        newInHitRect;
  357.         short                        i;
  358.         AOMModeBit                    newMode;
  359.         
  360. #define BUTTON    (*buttonPtr)
  361.  
  362.         newMode = AOM.currentMode;
  363.         buttonPtr = (AOMRadioButtonPtr) &_AOMRadioInfo[index];
  364.         if (BUTTON.modeBit == AOM.currentMode
  365.          || AOM.radioEnable[index] == FALSE) {
  366.             /*
  367.              * Do nothing if this is the currently-selected radio button
  368.              * or if this button is disabled.
  369.              */
  370.         }
  371.         else {
  372.             /*
  373.              * Track the button.
  374.              */
  375.             hitRect = RADIO(index);
  376.             _AOMPlotIcon(aomPtr, index, TRUE);
  377.             inHitRect = TRUE;
  378.             if (StillDown()) {
  379.                 while (WaitMouseUp()) {
  380.                     GetMouse(&mousePt);
  381.                     newInHitRect = PtInRect(mousePt, &hitRect);
  382.                     if (newInHitRect != inHitRect) {
  383.                         /*
  384.                          * The mouse moved in or out of the button.
  385.                          */
  386.                         inHitRect = newInHitRect;
  387.                         _AOMPlotIcon(aomPtr, index, inHitRect);
  388.                     }
  389.                 }
  390.             }
  391.             if (inHitRect) {
  392.                 /*
  393.                  * Now, find the previously selected radio button and deselect it.
  394.                  */
  395.                 for (i = 0; i < kAOMRadioButtons; i++) {
  396.                     if (_AOMRadioInfo[i].modeBit == AOM.currentMode) {
  397.                         _AOMPlotIcon(aomPtr, i, FALSE);
  398.                         break;                        /* Found it, exit now        */
  399.                     }                                /* Found the radio button    */
  400.                 }                                    /* For all radio buttons    */
  401.                 newMode = _AOMRadioInfo[index].modeBit;    /* New selection        */
  402.             }                                        /* User chose a new button    */
  403.         }                                            /* It's a selectable button    */
  404.         return (newMode);
  405. #undef BUTTON
  406. }
  407.  
  408.  
  409. /*
  410.  * Switch from AOM.currentMode to AOM.newMode
  411.  */
  412. void
  413. _AOMSelectMode(
  414.         register AddressOMaticPtr    aomPtr,
  415.         AOMModeBit                    newMode
  416.     )
  417. {
  418.         SDPPanelHandle                thePanel;
  419.         
  420.         if (AOM.currentMode != newMode) {
  421.             AOM.buttonUpdateNeeded = TRUE;                /* Check buttons        */
  422.             switch (AOM.currentMode) {                    /* Disable previous        */
  423.             case kAOMEnablePDBit:
  424.                 thePanel = AOM.pdPanel;
  425.                 goto deselectPanel;
  426.                 break;
  427.             case kAOMEnablePanelBit:
  428.                 thePanel = AOM.browsePanel;
  429. deselectPanel:    (void) _AOMPanelShow(aomPtr, thePanel, FALSE);
  430.                 (void) _AOMPanelSetFocus(aomPtr, thePanel, FALSE);
  431.                 (void) _AOMPanelEnable(aomPtr, thePanel, FALSE);
  432.                 break;
  433.             case kAOMEnableFindBit:
  434.                 (void) _AOMFindShow(aomPtr, FALSE);
  435.                 (void) _AOMFindStartStop(aomPtr, FALSE);    /* Stop finding        */
  436.                 (void) _AOMFindEnable(aomPtr, FALSE);
  437.                 break;
  438. #ifdef ENABLE_TYPEIN
  439.             case kAOMEnableTypeInBit:
  440.                 (void) _AOMTypeInShow(aomPtr, FALSE);
  441.                 break;
  442. #endif
  443.             }
  444.             EraseRect(&EXTERIOR);
  445.             AOM.currentMode = newMode;
  446.             switch (newMode) {                                /* Enable new        */
  447.             case kAOMEnablePDBit:
  448.                 thePanel = AOM.pdPanel;
  449.                 goto selectPanel;
  450.                 break;
  451.             case kAOMEnablePanelBit:
  452.                 thePanel = AOM.browsePanel;
  453. selectPanel:    (void) _AOMPanelEnable(aomPtr, thePanel, TRUE);
  454.                 (void) _AOMPanelSetFocus(aomPtr, thePanel, TRUE);
  455.                 (void) _AOMPanelShow(aomPtr, thePanel, TRUE);    
  456.                 break;
  457.             case kAOMEnableFindBit:
  458.                 (void) _AOMFindEnable(aomPtr, TRUE);        /* Enable find            */
  459.                 (void) _AOMFindShow(aomPtr, TRUE);            /* Show find            */
  460.                 break;
  461. #ifdef ENABLE_TYPEIN
  462.             case kAOMEnableTypeInBit:
  463.                 (void) _AOMTypeInShow(aomPtr, TRUE);
  464.                 break;
  465. #endif
  466.             }
  467.             _AOMDrawTitleString(aomPtr);
  468.         }
  469. }
  470.  
  471. /*
  472.  * The user hit the Enter or Return key. If the "To" button
  473.  * is enabled, treat it as a hit in the "To" button, else, it's
  474.  * the caller's responsibility.
  475.  */
  476. AOMPanelState
  477. _AOMDoEnterKey(
  478.         register AddressOMaticPtr    aomPtr
  479.     )
  480. {
  481.         if (AOM.toButton == NULL
  482.          || (**AOM.toButton).contrlHilite == kInactiveControl)
  483. {
  484.             return (kAOMAppMustHandleEventMask);
  485. }
  486.         else {
  487.             _AOMFlashButton(aomPtr, AOM.toButton);
  488.             return (_AOMDoToButtonHit(aomPtr, FALSE));
  489.         }
  490. }
  491.             
  492. /*
  493.  * The user clicked in the "To" button. If we are in the find
  494.  * panel, this may be a request to Start or Stop the find process.
  495.  */
  496. AOMPanelState
  497. _AOMDoToButtonHit(
  498.         register AddressOMaticPtr    aomPtr,
  499.         Boolean                        isButtonHit
  500.     )
  501. {
  502.         AOMPanelState                result;
  503.         SDPFindPanelState            findState;
  504.         SDPSelectionState            selectionState;
  505.         SDPPanelState                whatHappened;
  506.         OSErr                        status;        
  507.         SDPPanelHandle                thePanel;
  508.         
  509.         result = 0;
  510.         AOM.buttonUpdateNeeded = TRUE;
  511.         switch (AOM.currentMode) {
  512.         case kAOMEnablePDBit:
  513.             thePanel = AOM.pdPanel;
  514.             goto hitPanel;
  515.         case kAOMEnablePanelBit:
  516.             thePanel = AOM.browsePanel;
  517. hitPanel:    /*
  518.              * If a container is chosen, open it, else return
  519.              * the "to button hit" to the user.
  520.              */
  521.             status = SDPGetPanelSelectionState(
  522.                         thePanel,
  523.                         &selectionState
  524.                     );
  525.             if (status == noErr) {
  526.                 switch (selectionState) {
  527.                 default:
  528.                 case kSDPNothingSelected:
  529.                 case kSDPLockedContainerSelected:
  530.                     break;
  531.                 case kSDPContainerAliasSelected:
  532.                 case kSDPContainerSelected:
  533.                     status = SDPOpenSelectedItem(
  534.                                 thePanel,
  535.                                 &whatHappened
  536.                             );
  537.                     break;
  538.                 case kSDPRecordSelected:
  539.                 case kSDPRecordAliasSelected:
  540.                     if (isButtonHit
  541.                      || whatHappened == kSDPSelectedAnItem
  542.                      || whatHappened == kSDPChangedSelection) {
  543.                          if (isButtonHit == FALSE)
  544.                             _AOMFlashButton(aomPtr, AOM.toButton);
  545.                         result = (AOM.optKeyDown)
  546.                                 ? kAOMSaveButtonHitMask
  547.                                 : kAOMToButtonHitMask;
  548.                         result |= (whatHappened == kSDPSelectedAnItem)
  549.                                 ? kAOMSelectedAnItemMask
  550.                                 : kAOMChangedSelectionMask;
  551.                     }
  552.                     break;
  553.                 }
  554.             }
  555.             break;
  556.         case kAOMEnableFindBit:
  557.             status = SDPGetFindPanelState(AOM.findPanel, &findState);
  558.             LOG(status, "\pSDPGetFindPanelState");
  559.             if (FINDING) {
  560.                 _AOMFindStartStop(aomPtr, FALSE);
  561.                 result = 0;
  562.             }
  563.             else if ((findState & kSDPItemIsSelectedMask) != 0) {
  564.                 result = (AOM.optKeyDown)
  565.                         ? kAOMSaveButtonHitMask
  566.                         : kAOMToButtonHitMask;
  567.             }
  568.             else if ((findState & kSDPFindTextExistsMask) != 0) {
  569.                 _AOMFindStartStop(aomPtr, TRUE);
  570.                 result = 0;
  571.             }
  572.             else {
  573.                 result = 0;
  574.             }
  575.             break;
  576. #ifdef ENABLE_TYPEIN
  577.         case kAOMEnableTypeInBit:
  578.             result = (AOM.optKeyDown)
  579.                     ? kAOMSaveButtonHitMask
  580.                     : kAOMToButtonHitMask;
  581.             break;
  582. #endif
  583.         }
  584.         return (result);
  585. }
  586.  
  587. /*
  588.  * Flash the "To" button. Note: this always updated the button text.
  589.  */        
  590. void
  591. _AOMFlashButton(
  592.         register AddressOMaticPtr    aomPtr,
  593.         ControlHandle                theControl
  594.     )
  595. {
  596. #pragma unused (aomPtr)
  597.         long                        finalTicks;
  598.         AOMSaveState                saveState;
  599.  
  600.         /*
  601.          * theControl will be NULL if the user forgot to
  602.          * create one.
  603.          */
  604.         _AOMSetButtonText(aomPtr);
  605.         if (theControl != NULL) {
  606.             _AOMSaveState(aomPtr, kAOMLabelFontStyle, &saveState);
  607.             HiliteControl(theControl, inButton);
  608.             Delay(8, &finalTicks);
  609.             HiliteControl(theControl, 0);
  610.             _AOMRestoreState(&saveState);
  611.         }
  612. }
  613.